#include <cstring>
#include <iostream>
#include <string>
using namespace std;

int a, b, c, d, e, wr, p;

string d2b(int x) {
    string ans = "";
    while (x) {
        ans = (char)(x % 2 + '0') + ans;
        x /= 2;
    }
    if (ans.length() != 8) {
        int n = ans.length();
        for (int i = 0; i < 8 - n; i++) ans = '0' + ans;
    }
    return ans;
}

string ip2b(string ip) {
    string ans = "";
    char* cs = (char*)ip.c_str();
    char* p = strtok(cs, ".");
    while (p) {
        ans += d2b(stoi((string)p));
        p = strtok(NULL, ".");
    }
    return ans;
}

bool valid_mask(string mask) {
    string s = ip2b(mask);
    if (s.length() != 32) return 0;
    if (s[0] == '0') return 0;
    int index = 0;
    while (index < 32 && s[index] == '1') index++;
    if (index == 32) return 0;
    while (index < 32 && s[index] == '0') index++;
    if (index != 32) return 0;
    return 1;
}

bool valid_ip(string ip) {
    string s = ip2b(ip);
    if (s.length() != 32) return 0;
    return 1;
}

long long ip2d(string ip) {
    long long ans = 0;
    char* cs = (char*)ip.c_str();
    char* p = strtok(cs, ".");
    long long bei = 255 * 255 * 255;
    while (p) {
        ans += stoi((string)p) * bei;
        bei /= 255;
        p = strtok(NULL, ".");
    }
    return ans;
}

bool private_ip(string ip) {
    long long numIP = ip2d(ip);
    long long a1 = ip2d("10.0.0.0");
    long long a2 = ip2d("10.255.255.255");
    long long b1 = ip2d("172.16.0.0");
    long long b2 = ip2d("172.31.255.255");
    long long c1 = ip2d("192.168.0.0");
    long long c2 = ip2d("192.168.255.255");
    if (numIP >= a1 && numIP <= a2) return 1;
    if (numIP >= b1 && numIP <= b2) return 1;
    if (numIP >= c1 && numIP <= c2) return 1;
    return 0;
}

char ip_type(string ip) {
    long long num = ip2d(ip);
    long long a1 = ip2d("1.0.0.0");
    long long a2 = ip2d("126.255.255.255");
    long long b1 = ip2d("128.0.0.0");
    long long b2 = ip2d("191.255.255.255");
    long long c1 = ip2d("192.0.0.0");
    long long c2 = ip2d("223.255.255.255");
    long long d1 = ip2d("224.0.0.0");
    long long d2 = ip2d("239.255.255.255");
    long long e1 = ip2d("240.0.0.0");
    long long e2 = ip2d("255.255.255.255");
    if (num >= a1 && num <= a2) return 'a';
    if (num >= b1 && num <= b2) return 'b';
    if (num >= c1 && num <= c2) return 'c';
    if (num >= d1 && num <= d2) return 'd';
    if (num >= e1 && num <= e2) return 'e';
    return ' ';
}

bool ignore(string ip) {
    long long num = ip2d(ip);
    long long a1 = ip2d("0.0.0.0");
    long long a2 = ip2d("0.255.255.255");
    long long b1 = ip2d("127.0.0.0");
    long long b2 = ip2d("127.255.255.255");
    if (num >= a1 && num <= a2) return 1;
    if (num >= b1 && num <= b2) return 1;
    return 0;
}

int main() {
    string s;
    while (cin >> s) {
        string ip;
        string mask;
        int delim = s.find('~');
        ip = s.substr(0, delim);
        mask = s.substr(delim + 1, s.length() - (delim + 1));

        if (ignore(ip)) continue;

        if (!valid_mask(mask) || !valid_ip(ip)) {
            wr++;
            continue;
        }
        if (private_ip(ip)) p++;
        char ipt = ip_type(ip);
        if (ipt == 'a') a++;
        if (ipt == 'b') b++;
        if (ipt == 'c') c++;
        if (ipt == 'd') d++;
        if (ipt == 'e') e++;
    }

    cout << a << " " << b << " " << c << " " << d << " " << e << " " << wr
         << " " << p << endl;
    return 0;
}